package ansi.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Texto {
	private static SimpleDateFormat simpleDia		= new SimpleDateFormat("dd/MM/yyyy");
	private static SimpleDateFormat simpleHora		= new SimpleDateFormat("HH:mm");
	private static SimpleDateFormat simpleDiaHora	= new SimpleDateFormat("dd/MM/yyyy HH:mm");
	public static String getStr(String str) {
		return str != null && !str.equals("") ? str.trim() : "";
	}
	public static Integer getInt(String str) {
		return str != null && !str.equals("") ? new Integer(str.trim()) : new Integer(0);
	}
	public static Double getDouble(String str) {
		return str != null && !str.equals("") ? new Double(str.trim()) : new Double(0d);
	}
	public static String getStrDate(Date date) {
		return simpleDia.format(date);
	}
	public static String getStrHora(Date date) {
		return simpleHora.format(date);
	}
	public static String getStrDateHora(Date date) {
		return simpleDiaHora.format(date);
	}
	public static Date getDateFromStr(String str) {
		try {
			return simpleDia.parse(str);
		} catch(Exception ex) {}
		return null;
	}
	public static Date getHoraFromStr(String str) {
		try {
			return simpleHora.parse(str);
		} catch(Exception ex) {}
		return null;
	}
	public static Date getDateHoraFromStr(String str) {
		try {
			return simpleDiaHora.parse(str);
		} catch(Exception ex) {}
		return null;
	}
}
